//   
//   YourRootViewController.swift
//   BaseComponetKit
//   Created  by monkey on 2024/4/2
//   
//   
   
// YourRootViewController.swift

import UIKit
class MainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 创建第一个视图控制器
        let HomeViewController = HomeViewController()
        HomeViewController.title = "First"
        HomeViewController.tabBarItem = UITabBarItem(title: "主页", image: UIImage(named: "tarbar-1-home"), selectedImage: nil)
        
        // 创建第二个视图控制器
        let UserProfileSettingsViewController = UserProfileSettingsViewController()
        UserProfileSettingsViewController.title = "Second"
        UserProfileSettingsViewController.tabBarItem = UITabBarItem(title: "财富", image: UIImage(named: "tarbar-2-money"), selectedImage: nil)
        
        // 设置 tabBar 的背景颜色
        self.tabBar.barTintColor = UIColor.red // tabBar 的背景颜色
        self.tabBar.backgroundColor = UIColor.white // tabBar 的背景颜色

        // 设置选项卡标题的文字颜色
        let normalAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray]
        let selectedAttributes = [NSAttributedString.Key.foregroundColor: UIColor.blue]
        UITabBarItem.appearance().setTitleTextAttributes(normalAttributes, for: .normal)
        UITabBarItem.appearance().setTitleTextAttributes(selectedAttributes, for: .selected)
        
        // 将视图控制器添加到选项卡栏中
        self.viewControllers = [HomeViewController, UserProfileSettingsViewController]
    }
}

extension UIColor {
    static var gold: UIColor {
        return UIColor(red: 255/255, green: 215/255, blue: 0, alpha: 1.0)
    }
}
